import {connect} from 'react-redux';
import {Link} from 'react-router';
import action from '../action';

class Home extends React.Component {
    componentDidMount(){
        this.props.init();
    }

    render(){
        return (
            <div>
                <h1>这里{this.props.homeData.title}（{this.props.text}）</h1>
                <p>{this.props.homeData.desc}</p>
                <Link to="/about">>> 关于我们</Link>
            </div>
        )
    }
}

//主要给server端引用
Home.initAction=action.loadHomeData;

Home = connect(state => {
    const {homeData}=state;
    return {homeData};
}, dispatch => ({
    init(){
        dispatch(Home.initAction());
    }
}))(Home);

export default Home